package DataBase;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;

public class DatabaseHelper extends SQLiteOpenHelper {

	String createTable="create table TK_No(id integer primary key autoincrement,ngayno integer,ngaytra integer,sotien real,hoten  text,sodienthoai text,ghichu text);";
	String createTableLoaiHangString="create table loaihang(id integer primary key autoincrement,tenloai text,ghichu text,isthuchi integer);";
	String createTableChitieu="create table chitieu(id integer primary key autoincrement,tongtien real,ngay integer,loaithuchi integer,ghichu text,khoanchi text);";
	public DatabaseHelper(Context context, String name, CursorFactory factory,
			int version) {
		super(context, name, factory, version);
		// TODO Auto-generated constructor stub
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		// TODO Auto-generated method stub
		db.execSQL(createTable);
		db.execSQL(createTableChitieu);
		db.execSQL(createTableLoaiHangString);
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		// TODO Auto-generated method stub
		Droptable(db);
		onCreate(db);
	}
	void Droptable(SQLiteDatabase database)
	{
		
		database.execSQL("drop table if exists TK_No");
		database.execSQL("drop table if exists loaihang");
		database.execSQL("drop table if exists chitieu");
	}

}
